package finaldic;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Scanner;

public class localdic extends Dict{
	//实验四的代码
	  HashMap<String,String> hp;
	localdic(String path){
	    InputStream is =  this.getClass().getResourceAsStream(path);
		Scanner sc = new Scanner(is);
	    hp = new HashMap<String,String>();
	    while (sc.hasNextLine()) {
	      String in = sc.nextLine();
//	      System.out.println(in);
	      String[] info = in.split("\t");
	      if(info.length==2){
	    	  if(info[0].equals("a"))
	    		  System.out.println(info[0]+"     "+info[1]);
	        hp.put(info[0],info[1]);
	      }  else  {
	        hp.put(info[0], "暂未收录该单词的中文释义");
	      }  
	    }
	  }
	  public String translate(String word){
//		  System.out.println(hp.size());
	    return (String) hp.get(word);
	  }

}
